<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<p:dialog id="resource_edit_dialog" widgetVar="resource_edit_var" modal="true"
		header="#{resourceBean.model eq comm.m_a ? msgs.btnNew :(resourceBean.model eq comm.m_q ? msgs.btnQuery : (resourceBean.model eq comm.m_m ? msgs.btnEdit : (resourceBean.model eq comm.m_r ? msgs.btnRemove : '')))}资源信息" resizable="false" width="500">

		<h:form prependId="false" id="resource_edit_form">
			<p:focus context="resource_edit_form"/>
			
			<h:panelGrid columns="4" columnClasses="column1,column2,column1,column2">
				<h:outputText value="资源编码：" />
				<h:column>
					<p:inputText value="#{resourceBean.instance.code}" maxlength="50"
						disabled="#{resourceBean.model eq comm.m_q}" label="资源编码：">
						<f:validator validatorId="validator" />
						<f:attribute name="req_trim" value="true"/>
						<f:attribute name="req_notnull" value="true" />
						<f:attribute name="max_length" value="50"/>
					</p:inputText>
					<h:outputText value="*" style="color: red;" />
				</h:column>
				<h:outputText value="资源名称：" />
				<h:column>
					<p:inputText value="#{resourceBean.instance.name}" maxlength="50"
						disabled="#{resourceBean.model eq comm.m_q}" label="资源名称：">
						<f:validator validatorId="validator" />
						<f:attribute name="req_trim" value="true"/>
						<f:attribute name="req_notnull" value="true" />
						<f:attribute name="max_length" value="50"/>
					</p:inputText>
					<h:outputText value="*" style="color: red;" />
				</h:column>
			</h:panelGrid>
			
			<h:panelGrid columns="2" columnClasses="column1">
				<h:outputText value="资源路径：" />
				<p:inputText value="#{resourceBean.instance.url}" maxlength="250"
					disabled="#{resourceBean.model eq comm.m_q}" label="资源路径：" style="width: 362px;">
				</p:inputText>
			</h:panelGrid>
			
			<h:panelGrid columns="4" columnClasses="column1,column2,column1,column2">
				<h:outputText value="资源类型：" />
				<h:column>
					<h:selectOneMenu value="#{resourceBean.instance.type}" disabled="#{resourceBean.model eq comm.m_q}"
						styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all" label="资源类型：">
						<f:validator validatorId="validator" />
						<f:attribute name="req_notnull" value="true" />
						<f:selectItems value="#{appInfo.getDictsByRootcode(resourceBean.rootType)}" var="dict"
							itemLabel="#{dict.name}" itemValue="#{dict.value}"/>
					</h:selectOneMenu>
					<h:outputText value="*" style="color: red;" />
				</h:column>
				<h:outputText value="父资源：" />
				<h:column>
					<h:selectOneMenu value="#{resourceBean.instance.parentId}" disabled="#{resourceBean.model eq comm.m_q}"
						styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all" label="父资源：">
						<f:validator validatorId="validator" />
						<f:attribute name="req_notnull" value="true" />
						<f:selectItem itemLabel="无父级资源" itemValue="0"/>
						<f:selectItems value="#{resourceBean.parentResources}" var="parent"
							itemLabel="#{parent.name}" itemValue="#{parent.id}"/>
					</h:selectOneMenu>
					<h:outputText value="*" style="color: red;" />
				</h:column>
			</h:panelGrid>
			
			<h:panelGrid columns="2" columnClasses="column1">
				<h:outputText value="备注：" />
				<p:inputTextarea value="#{resourceBean.instance.note}" style="width: 362px; height: 50px;"
					autoResize="true" disabled="#{resourceBean.model eq comm.m_q}" label="备注：" maxlength="255">
				</p:inputTextarea>
				
				<h:outputText value="#{msgs.valid}：" />
				<h:selectOneRadio value="#{resourceBean.instance.status}" disabled="#{resourceBean.model eq comm.m_q}" label="#{msgs.valid}：">
					<f:validator validatorId="validator" />
					<f:attribute name="req_notnull" value="true" />
					<f:selectItem itemLabel="#{msgs.valid_y}" itemValue="1"/>
					<f:selectItem itemLabel="#{msgs.valid_n}" itemValue="1024"/>
				</h:selectOneRadio>
			</h:panelGrid>
			
			<div style="text-align: center;">
				<p:commandButton icon="#{comm.saveClass}" value="#{msgs.btnSave}" action="#{resourceBean.doAction}"
					oncomplete="handleResource(xhr, status, args);" update=":option_info"
					disabled="#{resourceBean.model eq comm.m_q}"/>
				<p:commandButton icon="#{comm.cancelClass}" value="#{msgs.btnCancel}" type="button" onclick="resource_edit_var.hide();"/>
			</div>
		</h:form>
		<script type="text/javascript">
			function handleResource(xhr, status, args) {
				if(args.option_result == 'success') {
					resource_edit_var.hide();
				}
			}
		</script>
	</p:dialog>

</ui:composition>